package leetcode_2501_2600;

public class LeeCode_2591 {
    public static void main(String[] args) {
        System.out.println(distMoney(20, 3));
        System.out.println(distMoney(17, 2));
    }

    private static int distMoney(int money, int children) {
        int ans = 0;
        if (money < children){
            return -1;
        }
        while (money - 8 >= children - 1 && !(money - 8 == 4 && children - 1 == 1) && children > 1) {
            money -= 8;
            ans++;
            children--;
        }
        if (children == 1 && money == 8){
            ans++;
        }
        return ans;
    }
}
